package com.zyh.mapper;

import com.zyh.entity.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

@Mapper
@Repository
public interface Bookmapper {

    List<Book> getAllBook(Book book);

    public Integer getBookCount(Book book);
@Select("select count(*) from t_book a LEFT JOIN t_borrow b ON a.bookId=id")
    public Integer getBorrowBookCount(BorrowBookVo borrowBookVo);


    public BorrowBookVo selectBook(Integer id);


    public Integer updateBookWithId( Book book);

    @Insert( "INSERT INTO t_book (bookname,isbn,press,author,number,surplus,categoryId,vailbookId) " +
            "VALUES (#{bookname},#{isbn},#{press},#{author},#{number},#{surplus},#{categoryId},#{vailbookId})")
    @Options(useGeneratedKeys = true, keyProperty = "bookid", keyColumn = "bookid")
    public Integer addBook(Book book);

    public Integer BorrowBookWithId( Book book);

    List<BorrowBookVo> getBorrowBook(BorrowBookVo borrowBookVo);

    public Integer getBorrowCount(BorrowBookVo borrowBookVo);

    public Integer BorrowBookWithIds(Integer[] id);

    public Integer SendBookWithId(BorrowBookVo borrowBookVo);

//    public List<BorrowBookVo> selectbyuserid(HashMap p);
    public List<BorrowBookVo> selectbyuserid(BorrowBookVo borrowBookVo);


    public Integer addBorrow(List<BorrowBookVo> borrowBookVos);

    public Integer sendBorrow(List<BorrowBookVo> borrowBookVos);


    List<BorrowBookVo> getBorrowHistory(BorrowBookVo borrowBookVo);





}
